/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package GUILayer;
import javax.swing.*;
import java.util.ArrayList;
import java.util.List;
import ModelLayer.*;

/**
 *
 * @author Gruppe 4
 */
public class ListModelSupplier extends DefaultListModel
{
    private ArrayList<Supplier> data;
    private String textField;
    
    public ListModelSupplier()
    {
        data = new ArrayList<Supplier>();
    }
    
    @Override
    public int getSize() 
    {
        return data.size();
    }
    
    @Override
    public void clear() 
    {
        data.clear();
        fireContentsChanged(this, 0, getSize());
    }
    
    public void setData(ArrayList<Supplier> data)
    {
        this.data = data;
        fireContentsChanged(this,0,data.size());
    }

    public List<Supplier> getData() 
    {
        return data;
    }
    
    public Object getElementAt2(int index) 
    {
        Object value = null;
        value = data.get(index);
               
        return value;
    }    

    @Override
    public Object getElementAt(int index) 
    {
        Object value = null;
        value = data.get(index).getName();
   
        return value;
    }  
    
    public Supplier getElementAtIndex(int index) 
    {
        Object value = null;
        value = data.get(index);
                  
        return (Supplier) value;
    }
    
    public void setText(String text)
    {
        textField = text;
    }         
}
